package com.fling.game;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.fling.Constants;
import com.fling.Locator;
import com.fling.block.BlockHandler;
import com.fling.objects.Hero;
import com.fling.objects.WallHandler;
import com.fling.observer.Subject;

public class GameInstance implements Constants{

	private Hero hero;
	private WallHandler wallLeft;
	private WallHandler wallRight;
	private BlockHandler blocks;
	private Subject subject;

	public GameInstance(int difficulty, Subject subject){
		hero=new Hero(new Vector2(WALL_WIDTH* Locator.getxSpriteScale(), VIRTUAL_HEIGHT * Locator.getySpriteScale()/2), subject);
		wallLeft=new WallHandler(0);
		wallRight=new WallHandler(VIRTUAL_WIDTH * Locator.getxSpriteScale() - WALL_WIDTH* Locator.getxSpriteScale());
		this.subject=subject;
		blocks=new BlockHandler(hero, subject);
	}
	
	public void render(SpriteBatch sb){
		hero.render(sb);
		wallLeft.render(sb);
		wallRight.render(sb);
		blocks.render(sb);
	}
	
	public void update(float delta){
		hero.update(delta);
		wallLeft.update(delta);
		wallRight.update(delta);
		blocks.update(delta);
	}
	
	public void restart(){
		blocks.delete();
		hero.setPosition(new Vector2(WALL_WIDTH* Locator.getxSpriteScale(), VIRTUAL_HEIGHT * Locator.getySpriteScale()/2));
		hero.restart();
	}

	public Hero getHero() {
		return hero;
	}

	public void setHero(Hero hero) {
		this.hero = hero;
	}

    public void init() {
        wallLeft.switchDifficulty();
        wallRight.switchDifficulty();
        blocks.reset();
        
    }

	public Subject getSubject() {
		return subject;
	}

	public void setSubject(Subject subject) {
		this.subject = subject;
	}
	
	
}
